﻿<cfmodule template="../../tag/layout.cfm">
<form method="post" class="form">
  <fieldset>
    <legend>资源基本信息</legend>
    <table class="table" width="100%">
      <tbody>
        <tr>
          <th>编号</th>
          <td><input name="id" readonly /></td>
          <th>&nbsp;</th>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <th>资源名称</th>
          <td><input name="text" class="easyui-validatebox" data-options="required:true" /></td>
          <th>资源路径</th>
          <td><input name="url" /></td>
        </tr>
        <tr>
          <th>资源说明</th>
          <td><input name="description" />
          </td>
          <th>资源类型</th>
          <td>
          <select id="resourcetypeid" name="resourcetypeid"></select>
          </td>
        </tr>
        <tr>
          <th>资源排序</th>
          <td><input name="seq" class="easyui-validatebox easyui-numberspinner"  data-options="min:0,max:100,required:true" value="0"  style="width:50px;" /></td>
          <th>上级资源</th>
          <td>
          	<select id="resourceid" name="resourceid">
          	</select>
          	<img class="iconImg ext-icon-cross" onclick="$('#resourceid').combotree('clear');" title="清空" />
          </td>
        </tr>
      </tbody>
    </table>
  </fieldset>
</form>
</cfmodule>
<cfscript>
	if( structKeyExists(rc, "id")  && rc.id > 0 ){
		id = rc.id;
	}else{
		id = 0;
	}
</cfscript>
<script type="text/javascript">
	var closeDialog = function($dialog) {
		$dialog.dialog('destroy');
	}

	var submitNow = function($dialog, $grid, $pjq) {
		var url;
		if ($(':input[name="id"]').val().length > 0) {
			url = '?action=resource.update'; //更新操作
		} else {
			url = '?action=resource.save';	//新增操作
		}

		$.post(url, fw.serializeObject($('form')), function(result) {
			if (result) {
				//$grid.treegrid('reload');
				$dialog.dialog('destroy');
			}
		}, 'json');
	};

	var submitForm = function($dialog, $grid, $pjq) {
		if ($('form').form('validate')) {
			submitNow($dialog, $grid, $pjq);
		}
	};


	$(function(){

		//选择资源类型
		var resourcetypeid
		resourcetypeid = $('#resourcetypeid').combobox({
				required:true,
				editable:false,
				valueField:'id',
				textField:'name',
				url:'?action=resource.getResourcetype',
				panelHeight:'auto'
		});

		//选择父Id
		var resourceid;
		resourceid = $('#resourceid').combotree({
				editable:false,
				idField:'id',
				textField:'text',
				parentField:'pid',
				url:'?action=resource.getTree'
		});

		//加载数据，初始进度条
		parent.$.messager.progress({
			text : '数据加载中....'
		});

		$.ajax({
		    type: "POST",
		    url: "?action=resource.get",
		    data: {
		        id:<cfoutput>#id#</cfoutput>
		    }
		}).done(function(result) {
			$('form').form('load', result);
			parent.$.messager.progress('close');

		}, 'json');
	})
</script>
